<?php
/**
 *  💡 免责声明：本软件不得用于商业用途，仅做学习交流
 *  ⚠️ 权利声明：本软件由版权人提供产品技术支持
 *  📅 项目编号：NX2025-0135
 */
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateMemberTopupOrdersTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('member_topup_orders', function (Blueprint $table) {
            $table->id();
            // 基础信息
            $table->string('order_no', 32)->unique()->comment('订单号');
            $table->unsignedBigInteger('user_id')->comment('用户ID');
            $table->decimal('amount', 10, 2)->comment('充值金额');

            // 支付信息
            $table->tinyInteger('payment_gateway')->default(2)->comment('1-alipay 2-wechat 3-balance');
            $table->string('certificate')->nullable()->comment('支付凭证');
            $table->string('remark')->nullable()->comment('备注');

            // 状态控制
            $table->tinyInteger('status')->default(0)->comment('状态: 0-待支付 1-已支付 2-已取消');
            $table->tinyInteger('review')->default(0)->comment('状态: 0-待审核 1-已审核 2-已驳回');
            $table->timestamps();
        });
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `member_topup_orders` comment '会员充值订单'");
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('member_topup_orders');
    }
}
